/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package facebooksharing;

import java.io.File;
import javax.swing.filechooser.FileFilter;

/**
 *
 * @author casa
 */
public class MyFileFilter extends FileFilter {

    @Override
    public boolean accept(File f) {
        if (f.isDirectory()) {
            return true;
        }
 
        if(f.getName() != null && f.getName().lastIndexOf(".") != -1) {
            String extension = f.getName().substring(f.getName().lastIndexOf(".") + 1).toLowerCase();
            if (extension.equals("jpeg") ||
                extension.equals("jpg") ||
                extension.equals("png")) {
                    return true;
            }
        }
 
        return false;
    }

    @Override
    public String getDescription() {
        return "Somente imagens.";
    }
}
